perm filename PROB[1,RWF] blob sn#354118 filedate 1979-10-19 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	CS 106, both sections
C00010 ENDMK
CāŠ—;
CS 106, both sections
Problem 8 -- An exercise in the use of strings.
May 11, 1978

	We all know that English has many dialects.  Words have different
spellings, and sometimes very different meanings, in England, Australia,
and the United States.  For this assignment you will write a program which
does a mechanical (and sometimes imperfect) translation from one dialect
to another.  Input to the program will be found in two files.  In the first
file you will be given correspondences between terms in two dialects.  (Call
this the DICTIONARY.)  In the second file you will be given a text to translate.
(Call this the TEXT.)

	Your program should begin by reading the DICTIONARY.  The DICTIONARY
will be a sequence of lines each containing two WORDS.  (See below for the
precise definition of a WORD.)  The first word will be word in one dialect.
(Call this the SOURCE WORD.)  The second word will be the corresponding word
in the second dialect.  (Call this the TARGET WORD.)  Then your program should
read the TEXT, replacing any SOURCE WORD found with the corresponding TARGET
WORD.  There will be no ending sentinel in either file;  the DICTIONARY will
contain only lines with exactly two words; the TEXT will contain lines with
any arbitrary content (including blank lines for example.)  The EOF function
should be used to detect the end of each file.

	A WORD will be defined to be any sequence of adjacent alphabetic
characters  (i.e. "A" thru "Z" and "a" thru "z".)  WORDS may be separated
from one another by any non-alphabetic characters.  The separator will often
be a space, but comma, period, and other punctuation is also possible.
WORDS do not cross line boundaries; that is, the end of a line is also a
word separator.

	The output file created by your program should have no line in which
there are more than 70 characters.  The TEXT file may have longer or shorter
lines.  The lines in the output file should be as close as possible to 70
characters long.  More precisely, this means that including the first word
of the next line would cause the line to have more than 70 characters.

	Words in the TEXT may be capitalized or not according to
common usage.  The output should have the same "capitalization" as the TEXT.

	A short example follows:
Assume the dictionary contains:

	honour honor
	gentry rich

Assume the TEXT contains:

"There is no honour among thieves."  This is an old saying,
but it has little impact in our world today.  Honour, in fact, may be extinct
even among the gentry.

1234567890123456789012345678901234567890123456789012345678901234567890
Then the output file should contain (the line above is for reference):

"There is no honor among thieves."  This is an old saying, but it has
little impact in our world today.  Honor, in fact, may be extinct even
among the rich.